<?php

namespace App\Listeners;

use App\Events\OrderShipped;

use App\Http\Controllers\Admin\Member\Repository\Member;
use App\Notifications\InvoicePaid;
use App\PayOrder;
use Carbon\Carbon;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Contracts\Queue\ShouldQueue;

class SendShipmentNotification implements  ShouldQueue
{
    /**
     * Create the event listener.
     *
     * @return void
     */
    public function __construct()
    {
        //FFF
    }

    /**
     * Handle the event.
     *
     * @param  OrderShipped  $event
     * @return void
     */
    public function handle(OrderShipped $event)
    {
        $comboOrder=$event->comboOrder;
        $memebers=Member::where('is_worker',1)->get();
        $payOrder= PayOrder::where('out_trade_no',$comboOrder->outTradeNo)->first();
        foreach ($memebers as $k=>$v){
          $v->notify(new InvoicePaid('有人购买了一个套餐,请前往管理平台查看,时间:'.Carbon::now().'订单号:'.$comboOrder->outTradeNo.'订单名称: '.$payOrder->body));

        }
    }
}
